home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsIDeviceContext.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  23KB  |  565 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #ifndef nsIDeviceContext_h___
  40. #define nsIDeviceContext_h___
  41.  
  42. #include "nsISupports.h"
  43. #include "nsCoord.h"
  44. #include "nsRect.h"
  45. #include "nsIWidget.h"
  46. #include "nsIRenderingContext.h"
  47.  
  48. class nsIView;
  49. class nsIFontMetrics;
  50. class nsIWidget;
  51. class nsIDeviceContextSpec;
  52. class nsIAtom;
  53.  
  54. struct nsFont;
  55. struct nsColor;
  56.  
  57. //a cross platform way of specifying a native device context
  58. typedef void * nsNativeDeviceContext;
  59.  
  60. /* error codes for printer device contexts */
  61. #define NS_ERROR_GFX_PRINTER_BASE (1) /* adjustable :-) */
  62. /* Unix: print command (lp/lpr) not found */
  63. #define NS_ERROR_GFX_PRINTER_CMD_NOT_FOUND          \
  64.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+1)
  65. /* Unix: print command returned an error */  
  66. #define NS_ERROR_GFX_PRINTER_CMD_FAILURE            \
  67.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+2)
  68. /* no printer available (e.g. cannot find _any_ printer) */
  69. #define NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE  \
  70.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+3)
  71. /* _specified_ (by name) printer not found */
  72. #define NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND         \
  73.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+4)
  74. /* access to printer denied */
  75. #define NS_ERROR_GFX_PRINTER_ACCESS_DENIED          \
  76.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+5)
  77. /* invalid printer attribute (for example: unsupported paper size etc.) */
  78. #define NS_ERROR_GFX_PRINTER_INVALID_ATTRIBUTE      \
  79.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+6)
  80. /* printer not "ready" (offline ?) */
  81. #define NS_ERROR_GFX_PRINTER_PRINTER_NOT_READY     \
  82.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+8)
  83. /* printer out of paper */
  84. #define NS_ERROR_GFX_PRINTER_OUT_OF_PAPER           \
  85.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+9)
  86. /* generic printer I/O error */
  87. #define NS_ERROR_GFX_PRINTER_PRINTER_IO_ERROR       \
  88.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+10)
  89. /* print-to-file: could not open output file */
  90. #define NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE    \
  91.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+11)
  92. /* print-to-file: I/O error while printing to file */
  93. #define NS_ERROR_GFX_PRINTER_FILE_IO_ERROR          \
  94.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+12)
  95. /* print preview: needs at least one printer */
  96. #define NS_ERROR_GFX_PRINTER_PRINTPREVIEW          \
  97.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+13)
  98. /* print: starting document */
  99. #define NS_ERROR_GFX_PRINTER_STARTDOC          \
  100.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+14)
  101. /* print: ending document */
  102. #define NS_ERROR_GFX_PRINTER_ENDDOC          \
  103.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+15)
  104. /* print: starting page */
  105. #define NS_ERROR_GFX_PRINTER_STARTPAGE          \
  106.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+16)
  107. /* print: ending page */
  108. #define NS_ERROR_GFX_PRINTER_ENDPAGE          \
  109.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+17)
  110. /* print: print while in print preview */
  111. #define NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW          \
  112.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+18)
  113. /* requested page size not supported by printer */
  114. #define NS_ERROR_GFX_PRINTER_PAPER_SIZE_NOT_SUPPORTED \
  115.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+19)
  116. /* requested page orientation not supported */
  117. #define NS_ERROR_GFX_PRINTER_ORIENTATION_NOT_SUPPORTED \
  118.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+20)
  119. /* requested colorspace not supported (like printing "color" on a "grayscale"-only printer) */
  120. #define NS_ERROR_GFX_PRINTER_COLORSPACE_NOT_SUPPORTED \
  121.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+21)
  122. /* too many copies requested */
  123. #define NS_ERROR_GFX_PRINTER_TOO_MANY_COPIES \
  124.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+22)
  125. /* driver configuration error */
  126. #define NS_ERROR_GFX_PRINTER_DRIVER_CONFIGURATION_ERROR \
  127.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+23)
  128. /* Xprint module specific: Xprt server broken */
  129. #define NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT \
  130.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+24)
  131. /* The document is still being loaded, can't Print Preview */
  132. #define NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP \
  133.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+25)
  134. /* The document was asked to be destroyed while we were preparing printing */
  135. #define NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED \
  136.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+26)
  137. /* Cannot Print or Print Preview XUL Documents */
  138. #define NS_ERROR_GFX_PRINTER_NO_XUL \
  139.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+27)
  140. /* The toolkit no longer supports the Print Dialog (for embedders) */
  141. #define NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT \
  142.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+28)
  143. /* The was wasn't any Print Prompt service registered (this shouldn't happen) */
  144. #define NS_ERROR_GFX_NO_PRINTROMPTSERVICE \
  145.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+29)
  146. /* Xprint module specific: No Xprint servers found */
  147. #define NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND \
  148.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+30)
  149. /* requested plex mode not supported by printer */
  150. #define NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED \
  151.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+31)
  152. /* The document is still being loaded */
  153. #define NS_ERROR_GFX_PRINTER_DOC_IS_BUSY \
  154.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+32)
  155. /* Printing is not implemented */
  156. #define NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED \
  157.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+33)
  158. /* Cannot load the matching print module */
  159. #define NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE \
  160.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+34)   
  161. /* requested resolution/quality mode not supported by printer */
  162. #define NS_ERROR_GFX_PRINTER_RESOLUTION_NOT_SUPPORTED \
  163.   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+35)
  164.       
  165. /**
  166.  * Conts need for Print Preview
  167.  */
  168. #ifdef NS_PRINT_PREVIEW
  169. const PRUint8 kUseAltDCFor_NONE            = 0x00; // Do not use the AltDC for anything
  170. const PRUint8 kUseAltDCFor_FONTMETRICS     = 0x01; // Use it for only getting the font metrics
  171. const PRUint8 kUseAltDCFor_CREATERC_REFLOW = 0x02; // Use when creating RenderingContexts for Reflow
  172. const PRUint8 kUseAltDCFor_CREATERC_PAINT  = 0x04; // Use when creating RenderingContexts for Painting
  173. const PRUint8 kUseAltDCFor_SURFACE_DIM     = 0x08; // Use it for getting the Surface Dimensions
  174. #endif
  175.  
  176. #define NS_IDEVICE_CONTEXT_IID   \
  177. { 0xb31ad9ce, 0x40cb, 0x43c4, \
  178.   { 0x90, 0xf8, 0x0f, 0x30, 0x53, 0xf6, 0xb8, 0xea } }
  179.  
  180. //a cross platform way of specifying a native palette handle
  181. typedef void * nsPalette;
  182.  
  183.   //structure used to return information about a device's palette capabilities
  184.   struct nsPaletteInfo {
  185.      PRPackedBool  isPaletteDevice;
  186.      PRUint16      sizePalette;  // number of entries in the palette
  187.      PRUint16      numReserved;  // number of reserved palette entries
  188.      nsPalette     palette;      // native palette handle
  189.   };
  190.  
  191.   typedef enum {
  192.     eSystemFont_Caption,         // css2
  193.     eSystemFont_Icon,
  194.     eSystemFont_Menu,
  195.     eSystemFont_MessageBox,
  196.     eSystemFont_SmallCaption,
  197.     eSystemFont_StatusBar,
  198.  
  199.     eSystemFont_Window,          // css3
  200.     eSystemFont_Document,
  201.     eSystemFont_Workspace,
  202.     eSystemFont_Desktop,
  203.     eSystemFont_Info,
  204.     eSystemFont_Dialog,
  205.     eSystemFont_Button,
  206.     eSystemFont_PullDownMenu,
  207.     eSystemFont_List,
  208.     eSystemFont_Field,
  209.  
  210.     eSystemFont_Tooltips,        // moz
  211.     eSystemFont_Widget
  212.   } nsSystemFontID;
  213.  
  214. class nsIDeviceContext : public nsISupports
  215. {
  216. public:
  217.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_IID)
  218.  
  219.   /**
  220.    * Initialize the device context from a widget
  221.    * @param aWidget a native widget to initialize the device context from
  222.    * @return error status
  223.    */
  224.   NS_IMETHOD  Init(nsNativeWidget aWidget) = 0;
  225.  
  226.   /**
  227.    * Create a rendering context and initialize it from an nsIView
  228.    * @param aView view to initialize context from
  229.    * @param aContext out parameter for new rendering context
  230.    * @return error status
  231.    */
  232.   NS_IMETHOD  CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
  233.  
  234.   /**
  235.    * Create a rendering context and initialize it from an nsIDrawingSurface*
  236.    * @param nsIDrawingSurface* widget to initialize context from
  237.    * @param aContext out parameter for new rendering context
  238.    * @return error status
  239.    */
  240.   NS_IMETHOD  CreateRenderingContext(nsIDrawingSurface* aSurface, nsIRenderingContext *&aContext) = 0;
  241.  
  242.   /**
  243.    * Create a rendering context and initialize it from an nsIWidget
  244.    * @param aWidget widget to initialize context from
  245.    * @param aContext out parameter for new rendering context
  246.    * @return error status
  247.    */
  248.   NS_IMETHOD  CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
  249.  
  250.   /**
  251.    * Create a rendering context and initialize it. This API should *only* be called
  252.    * on device contexts whose SupportsNativeWidgets() method return PR_FALSE.
  253.    * @param aContext out parameter for new rendering context
  254.    * @return error status
  255.    */
  256.   NS_IMETHOD  CreateRenderingContext(nsIRenderingContext *&aContext) = 0;
  257.  
  258.   /**
  259.    * Create an uninitalised rendering context.
  260.    * @param aContext out parameter for new rendering context
  261.    * @return error status
  262.    */
  263.   NS_IMETHOD  CreateRenderingContextInstance(nsIRenderingContext *&aContext) = 0;
  264.  
  265.   /**
  266.    * Query the device to see if it supports native widgets. If not, then
  267.    * nsIWidget->Create() calls should be avoided.
  268.    * @param aSupportsWidgets out paramater. If PR_TRUE, then native widgets
  269.    *        can be created.
  270.    * @return error status
  271.    */
  272.   NS_IMETHOD  SupportsNativeWidgets(PRBool &aSupportsWidgets) = 0;
  273.  
  274.   /**
  275.    * Obtain the size of a device unit relative to a Twip. A twip is 1/20 of
  276.    * a point (which is 1/72 of an inch).
  277.    * @return conversion value
  278.    */
  279.   float DevUnitsToTwips() const { return mPixelsToTwips; }
  280.  
  281.   /**
  282.    * Obtain the size of a Twip relative to a device unit.
  283.    * @return conversion value
  284.    */
  285.   float TwipsToDevUnits() const { return mTwipsToPixels; }
  286.  
  287.   /**
  288.    * Set the scale factor to convert units used by the application
  289.    * to device units. Typically, an application will query the device
  290.    * for twips to device units scale and then set the scale
  291.    * to convert from whatever unit the application wants to use
  292.    * to device units. From that point on, all other parts of the
  293.    * app can use the Get* methods below to figure out how
  294.    * to convert device units <-> app units.
  295.    * @param aAppUnits scale value to convert from application defined
  296.    *        units to device units.
  297.    */
  298.   void SetAppUnitsToDevUnits(float aAppUnits)
  299.   {
  300.     mAppUnitsToDevUnits = aAppUnits;
  301.   }
  302.  
  303.   /**
  304.    * Set the scale factor to convert device units to units
  305.    * used by the application. This should generally be
  306.    * 1.0f / the value passed into SetAppUnitsToDevUnits().
  307.    * @param aDevUnits scale value to convert from device units to
  308.    *        application defined units
  309.    */
  310.   void SetDevUnitsToAppUnits(float aDevUnits)
  311.   {
  312.     mDevUnitsToAppUnits = aDevUnits;
  313.   }
  314.  
  315.   /**
  316.    * Get the scale factor to convert from application defined
  317.    * units to device units.
  318.    * @param aAppUnits scale value
  319.    */
  320.   float AppUnitsToDevUnits() const { return mAppUnitsToDevUnits; }
  321.  
  322.   /**
  323.    * Get the scale factor to convert from device units to
  324.    * application defined units.
  325.    * @param aDevUnits out paramater for scale value
  326.    * @return error status
  327.    */
  328.   float DevUnitsToAppUnits() const { return mDevUnitsToAppUnits; }
  329.  
  330.   /**
  331.    * Get the value used to scale a "standard" pixel to a pixel
  332.    * of the same physical size for this device. a standard pixel
  333.    * is defined as a pixel on display 0. this is used to make
  334.    * sure that entities defined in pixel dimensions maintain a
  335.    * constant relative size when displayed from one output
  336.    * device to another.
  337.    * @param aScale out parameter for scale value
  338.    * @return error status
  339.    */
  340.   NS_IMETHOD  GetCanonicalPixelScale(float &aScale) const = 0;
  341.  
  342.   /**
  343.    * Get the value used to scale a "standard" pixel to a pixel
  344.    * of the same physical size for this device. a standard pixel
  345.    * is defined as a pixel on display 0. this is used to make
  346.    * sure that entities defined in pixel dimensions maintain a
  347.    * constant relative size when displayed from one output
  348.    * device to another.
  349.    * @param aScale in parameter for scale value
  350.    * @return error status
  351.    */
  352.   NS_IMETHOD  SetCanonicalPixelScale(float aScale) = 0;
  353.  
  354.   /**
  355.    * Get the width of a vertical scroll bar and the height
  356.    * of a horizontal scrollbar in application units.
  357.    * @param aWidth out parameter for width
  358.    * @param aHeight out parameter for height
  359.    * @return error status
  360.    */
  361.   NS_IMETHOD  GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
  362.  
  363.   /**
  364.    * Fill in an nsFont based on the ID of a system font.  This function
  365.    * may or may not fill in the size, so the size should be set to a
  366.    * reasonable default before calling.
  367.    *
  368.    * @param aID    The system font ID.
  369.    * @param aInfo  The font structure to be filled in.
  370.    * @return error status
  371.    */
  372.   NS_IMETHOD  GetSystemFont(nsSystemFontID aID, nsFont *aFont) const = 0;
  373.  
  374.   /**
  375.    * Get the nsIFontMetrics that describe the properties of
  376.    * an nsFont.
  377.    * @param aFont font description to obtain metrics for
  378.    * @param aLangGroup the language group of the document
  379.    * @param aMetrics out parameter for font metrics
  380.    * @return error status
  381.    */
  382.   NS_IMETHOD  GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
  383.                             nsIFontMetrics*& aMetrics) = 0;
  384.  
  385.   /**
  386.    * Get the nsIFontMetrics that describe the properties of
  387.    * an nsFont.
  388.    * @param aFont font description to obtain metrics for
  389.    * @param aMetrics out parameter for font metrics
  390.    * @return error status
  391.    */
  392.   NS_IMETHOD  GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics) = 0;
  393.  
  394.   //get and set the document zoom value used for display-time
  395.   //scaling. default is 1.0 (no zoom)
  396.   NS_IMETHOD  SetZoom(float aZoom) = 0;
  397.   NS_IMETHOD  GetZoom(float &aZoom) const = 0;
  398.  
  399.   /**
  400.    * Check to see if a particular named font exists.
  401.    * @param aFontName character string of font face name
  402.    * @return NS_OK if font is available, else font is unavailable
  403.    */
  404.   NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
  405.   NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
  406.  
  407.   NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
  408.                               PRBool& aAliased) = 0;
  409.  
  410.   /**
  411.    * Notification when a font metrics instance created for this device is
  412.    * about to be deleted
  413.    */
  414.   NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics) = 0;
  415.  
  416.   /**
  417.    * Attempt to free up resoruces by flushing out any fonts no longer
  418.    * referenced by anything other than the font cache itself.
  419.    * @return error status
  420.    */
  421.   NS_IMETHOD FlushFontCache(void) = 0;
  422.  
  423.   /**
  424.    * Return the bit depth of the device.
  425.    */
  426.   NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
  427.  
  428.   /**
  429.    * Returns information about the device's palette capabilities.
  430.    */
  431.   NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo) = 0;
  432.  
  433.   /**
  434.    * Get the size of the displayable area of the output device
  435.    * in app units.
  436.    * @param aWidth out parameter for width
  437.    * @param aHeight out parameter for height
  438.    * @return error status
  439.    */
  440.   NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
  441.  
  442.   /**
  443.    * Get the size of the content area of the output device in app units.
  444.    * This corresponds on a screen device, for instance, to the entire screen.
  445.    * @param aRect out parameter for full rect. Position (x,y) will be (0,0) or
  446.    *              relative to the primary monitor if this is not the primary.
  447.    * @return error status
  448.    */
  449.   NS_IMETHOD GetRect ( nsRect &aRect ) = 0;
  450.  
  451.   /**
  452.    * Get the size of the content area of the output device in app units.
  453.    * This corresponds on a screen device, for instance, to the area reported
  454.    * by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar
  455.    * (Macintosh).
  456.    * @param aRect out parameter for client rect. Position (x,y) will be (0,0)
  457.    *              adjusted for any upper/left non-client space if present or
  458.    *              relative to the primary monitor if this is not the primary.
  459.    * @return error status
  460.    */
  461.   NS_IMETHOD GetClientRect(nsRect &aRect) = 0;
  462.  
  463.   /**
  464.    * Returns a new nsIDeviceContext suitable for the device context
  465.    * specification passed in.
  466.    * @param aDevice a device context specification. this is a platform
  467.    *        specific structure that only a platform specific device
  468.    *        context can interpret.
  469.    * @param aContext out parameter for new device context. nsnull on
  470.    *        failure to create new device context.
  471.    * @return error status
  472.    */
  473.   NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
  474.                                  nsIDeviceContext *&aContext) = 0;
  475.  
  476.   /**
  477.    * This is enables the DeviceContext to anything it needs to do for Printing
  478.    * before Reflow and BeginDocument is where work can be done after reflow.
  479.    * @param aTitle - itle of Document
  480.    * @param aPrintToFileName - name of file to print to, if NULL then don't print to file
  481.    *
  482.    * @return error status
  483.    */
  484.   NS_IMETHOD PrepareDocument(PRUnichar * aTitle, 
  485.                              PRUnichar*  aPrintToFileName) = 0;
  486.  
  487.   //XXX need to work out re-entrancy issues for these APIs... MMP
  488.   /**
  489.    * Inform the output device that output of a document is beginning
  490.    * Used for print related device contexts. Must be matched 1:1 with
  491.    * EndDocument().
  492.    * XXX needs to take parameters so that feedback can be given to the
  493.    * app regarding pagination progress and aborting print operations?
  494.    *
  495.    * @param aTitle - itle of Document
  496.    * @param aPrintToFileName - name of file to print to, if NULL then don't print to file
  497.    * @param aStartPage - starting page number (must be greater than zero)
  498.    * @param aEndPage - ending page number     (must be less than or equal to number of pages)
  499.    *
  500.    * @return error status
  501.    */
  502.   NS_IMETHOD BeginDocument(PRUnichar*  aTitle, 
  503.                            PRUnichar*  aPrintToFileName,
  504.                            PRInt32     aStartPage, 
  505.                            PRInt32     aEndPage) = 0;
  506.  
  507.   /**
  508.    * Inform the output device that output of a document is ending.
  509.    * Used for print related device contexts. Must be matched 1:1 with
  510.    * BeginDocument()
  511.    * @return error status
  512.    */
  513.   NS_IMETHOD EndDocument(void) = 0;
  514.  
  515.   /**
  516.    * Inform the output device that output of a document is being aborted.
  517.    * Must be matched 1:1 with BeginDocument()
  518.    * @return error status
  519.    */
  520.   NS_IMETHOD AbortDocument(void) = 0;
  521.  
  522.   /**
  523.    * Inform the output device that output of a page is beginning
  524.    * Used for print related device contexts. Must be matched 1:1 with
  525.    * EndPage() and within a BeginDocument()/EndDocument() pair.
  526.    * @return error status
  527.    */
  528.   NS_IMETHOD BeginPage(void) = 0;
  529.  
  530.   /**
  531.    * Inform the output device that output of a page is ending
  532.    * Used for print related device contexts. Must be matched 1:1 with
  533.    * BeginPage() and within a BeginDocument()/EndDocument() pair.
  534.    * @return error status
  535.    */
  536.   NS_IMETHOD EndPage(void) = 0;
  537.  
  538. #ifdef NS_PRINT_PREVIEW
  539.   /**
  540.    * Set an Alternative Device Context where some of the calls
  541.    * are deferred to it
  542.    */
  543.   NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC) = 0;
  544.  
  545.   /**
  546.    * Get the Alternate Device Context
  547.    */
  548.   NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) = 0;
  549.  
  550.   /**
  551.    * Turn on/off which types of information is retrived 
  552.    * via the alt device context
  553.    */
  554.   NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn) = 0;
  555. #endif
  556.  
  557. protected:
  558.   float mTwipsToPixels;
  559.   float mPixelsToTwips;
  560.   float mAppUnitsToDevUnits;
  561.   float mDevUnitsToAppUnits;
  562. };
  563.  
  564. #endif /* nsIDeviceContext_h___ */
  565.